package com.liiy.missyou.model;

import com.liiy.missyou.util.GenericAndJson;
import com.liiy.missyou.util.MapAddJson;
import jakarta.persistence.Convert;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.Collections;
import java.util.List;
import java.util.Map;

@Entity
@Getter
@Setter
@Table(name="ms_sku")
public class Sku extends BaseEntity{
    @Id
    private long id;
    private BigDecimal price;
    private BigDecimal discountPrice;
    private Boolean online;
    private String img;
    private String title;
    private Long spuId;
    private Long categoryId;
    private Long rootCategoryId;

    @Convert(converter = MapAddJson.class)
    private Map<String,Object> specs;
    private String code;
    private Long stock;

//    public List<Spec> getSpec() {
//        if (this.specs == null) {
//            return Collections.emptyList();
//        }
//        return GenericAndJson.jsonToList(this.specs);
//    }
//
//    public void setSpecs(List<Spec> specs) {
//        if (specs.isEmpty()) {
//            return;
//        }
//        this.specs = GenericAndJson.objectToJson(specs);
//    }
}
